
package com.zhitan.ems.app.iot.wrapper;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhitan.ems.app.iot.entity.DeviceEntity;
import com.zhitan.ems.app.iot.vo.DeviceOnlineVO;
import com.zhitan.ems.app.iot.vo.DeviceVO;
import com.zhitan.ems.common.extra.utils.BeanUtil;
import com.zhitan.ems.framework.core.mp.base.BaseEntityWrapper;
import com.zhitan.ems.framework.core.vo.VPage;
  /**
 * 设备 包装类,返回视图层所需的字段
 * @author zhitan
 * 
 * @date 2025-09-19 22:15:46
 */
public class DeviceWrapper extends BaseEntityWrapper<DeviceEntity, DeviceVO>  {
    public static DeviceWrapper build() {
        return new DeviceWrapper();
    }
	@Override
	public DeviceVO entityVO(DeviceEntity device) {
		if(device==null) {
			return null;
		}
		DeviceVO deviceVO = BeanUtil.copy(device, DeviceVO.class);
		return deviceVO;
	}
	public DeviceOnlineVO entityOnlineVO(DeviceEntity device) {
		if(device==null) {
			return null;
		}
		DeviceOnlineVO deviceVO = BeanUtil.copy(device, DeviceOnlineVO.class);
		return deviceVO;
	}
	public VPage<DeviceOnlineVO> toVPageOnlineVO(IPage<DeviceEntity> pages) {
		 List<DeviceOnlineVO> deviceOnlineVOs=pages.getRecords().stream().map(this::entityOnlineVO).collect(Collectors.toList());
		return new VPage<DeviceOnlineVO>(deviceOnlineVOs,pages.getTotal(),pages.getSize(),pages.getCurrent());
	}
}
